<?php
// ====================================================
// filename:wl101_delete_batch.php
// summary: 用户管理画面_批量删除处理
// ====================================================
require_once ("../init.php");
php_handle();

function php_handle()
{
    $uid = $_SESSION['wl_uid'];
    $list = isset($_POST['list']) ? json_decode($_POST['list']) : "";
    
    $db = new mysql();
    $dbh = $db->db_connection();
    
    try {
        $dbh->beginTransaction();
        $wlu02 = new wlu02tbx($dbh);
        
        for ($i = 0; $i < count($list); $i ++) {
            $u02del = array();
            $u02del["user_id"] = $list[$i];
            
            $u02rec = $wlu02->delete($uid, $u02del);
            if ($u02rec == 0) {
                $dbh->rollback();
                echo json_encode(array(
                    'success' => false,
                    'msg' => "用户删除失败！"
                ));
                return;
            }
        }
        
        $dbh->commit();
    } catch (PDOException $e) {
        
        // 数据库操作失败，操作回滚
        $dbh->rollback();
        echo json_encode(array(
            'success' => false,
            'msg' => $e->getMessage()
        ));
        return;
    }
    
    echo json_encode(array(
        'success' => true,
        'data' => count($list)
    ));
}

?>
